﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Diploma.Models;
using DiplomaWeb.Models.Reviewer;
using DiplomaWeb.Models.Student;

namespace DiplomaWeb.Controllers
{
    [Authorize(Roles = "Reviewer")]
    public class ReviewerController : MasterController
    {
        public ReviewerController(DataManager dataManager) : base(dataManager)
        {
        }

        public ActionResult Index()
        {
            var viewModel = new StudentProgressViewModel();
            viewModel.ToViewModel(DataManager.StudentsGroupsRepository.GetAllGroups());
            return View(viewModel);
        }

        [HttpPost]
        public ActionResult Index(StudentProgressViewModel model)
        {
            DataManager.StudentsRepository.UpdateUserProperties(model.Id, model.ThemeWithOrder, model.Notice, model.Feedback, model.SignatureNormControl, model.PreliminaryPresentation,
                model.SignatureLecturer, model.SignatureStudent, model.SignatureConsultants, model.Slides, model.Archive);
            model.ToViewModel(DataManager.StudentsGroupsRepository.GetAllGroups());
            model.IsSaved = true;
            return View(model);
        }

        public PartialViewResult StudentsPart(Guid groupId)
        {
            var viewModel = new StudentListViewModel();
            viewModel.ToViewModel(DataManager.StudentsRepository.GetStudents(groupId));
            return PartialView(viewModel);
        }

        public PartialViewResult StudentProperties(Guid studentId)
        {
            var viewData = new StudentProgressViewModel();
            viewData.ToViewModel(DataManager.StudentsRepository.GetStudent(studentId));
            return PartialView(viewData);
        }
    }
}
